using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using T2.Logging.Data.Controllers.Interfaces;
using T2.Logging.Data.Entities.Interfaces;
using T2.Logging.Business.Entities.Interfaces;
using T2.Logging.Business.Entities;
using T2.Logging.Business.Builders;
using T2.Logging.Business.Directors.Interface;
using T2.Logging.Business.Entities.Search.Interfaces;

//--Change Management Control - Tenant Director  --**********************
//--Created By: trooks
//--Description: Tenant Director Class
//--Created Date: 03/07/2013 10:05:40
//--*************************************************************

namespace T2.Logging.Business.Directors
{
	public partial class Tenant_Director_biz : ITenant_director_biz
	{
		
		public List<ITenant_biz> Construct (ITenant_biz _param, bool BuildUp, bool BuildDown)
		{
			Tenant_Builder build = new Tenant_Builder();
			List<ITenant_biz> retVal = build.BuildParts(_param);
			foreach(ITenant_biz item in retVal)
			{
				item.Application_List = BuildApplicationList(item, false, BuildDown);
		}
			return retVal;
		}
		public List<ITenant_biz> Construct (ITenantSearch_biz _param, bool BuildUp, bool BuildDown)
		{
			Tenant_Builder build = new Tenant_Builder();
			List<ITenant_biz> retVal = build.BuildParts(_param);
			foreach(ITenant_biz item in retVal)
			{
				item.Application_List = BuildApplicationList(item, false, BuildDown);
		}
			return retVal;
		}
		private List<IApplication_biz> BuildApplicationList(ITenant_biz _param, bool BuildUp, bool BuildDown)
		{
			List<IApplication_biz> retVal = new List<IApplication_biz>();
			if(BuildDown)
			{
			IApplication_biz ApplicationParam = new Application_biz();
			ApplicationParam.Action ="Tenant_Application_ByParent";
			ApplicationParam.PageNumber = 1;
			ApplicationParam.PageSize = 100;
			ApplicationParam.SortType = "asc";
			ApplicationParam.SortColumn = "ApplicationID";
			ApplicationParam.TenantID = _param.TenantID;
			Application_Builder builder = new Application_Builder();
			retVal = builder.BuildParts(ApplicationParam);
			}
			return retVal;
		}
	}
}